package com.retail.proxy.controller;

import com.retail.core.common.AbstractCommonController;
import com.retail.core.entity.ParamReq;

import com.retail.core.entity.result.PageResult;
import com.retail.core.entity.result.Result;
import com.retail.global.security.LoginUserUtil;
import com.retail.global.annon.TraceLog;
import com.retail.proxy.entity.request.AdminProxyUpgradeDetailRequest;
import com.retail.proxy.entity.vo.AdminProxyUpgradeDetailVo;
import com.retail.proxy.service.AdminProxyUpgradeDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 晋升明细 API
* @author Administrator
*/
@Api(tags = "晋升明细 API")
@RestController
@RequestMapping("/adminProxyUpgradeDetail")
public class AdminProxyUpgradeDetailController extends AbstractCommonController<AdminProxyUpgradeDetailService, AdminProxyUpgradeDetailRequest, AdminProxyUpgradeDetailVo>{

    @Autowired
    private AdminProxyUpgradeDetailService adminProxyUpgradeDetailService;

    @TraceLog()
    @GetMapping("{id}")
    public Result getModel(@PathVariable("id") Long id) {
        return super.getModel(adminProxyUpgradeDetailService, id);
    }

    @TraceLog()
    @PostMapping
    @ApiOperation("保存晋升明细")
    public Result<Integer> save(@RequestBody AdminProxyUpgradeDetailRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.save(adminProxyUpgradeDetailService, request);
    }

    @TraceLog()
    @PutMapping
    @ApiOperation("更新晋升明细")
    public Result<Integer> update(@RequestBody AdminProxyUpgradeDetailRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.update(adminProxyUpgradeDetailService, request);
    }

    @TraceLog()
    @PostMapping("listPage")
    @ApiOperation("晋升明细-查询")
    public Result<List<AdminProxyUpgradeDetailVo>>listPage(@RequestBody ParamReq req) {
        return super.listPage(adminProxyUpgradeDetailService, req);
    }

    @TraceLog()
    @PostMapping("countPage")
    @ApiOperation("晋升明细-统计")
    public Result<Integer> countPage(@RequestBody ParamReq req) {
        return super.countPage(adminProxyUpgradeDetailService, req);
    }

    @TraceLog()
    @PostMapping("page")
    @ApiOperation("晋升明细-分页数据")
    public Result<PageResult> page(@RequestBody ParamReq<AdminProxyUpgradeDetailRequest> req) {
        return super.page(adminProxyUpgradeDetailService, req);
    }

    @TraceLog()
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除晋升明细")
    public Result<Integer> delete(@PathVariable("id") Long id) {
        return super.delete(adminProxyUpgradeDetailService, id);
    }

    @TraceLog()
    @ApiOperation("批量删除晋升明细")
    @DeleteMapping("{ids}")
    public Result<Integer> batchDelete(List<Long> ids) {
        return super.batchDelete(adminProxyUpgradeDetailService, ids);
    }

    @TraceLog()
    @ApiOperation("明细")
    @GetMapping("proxyUpgradeDetailList/{upgradeId}")
    public Result<List<AdminProxyUpgradeDetailVo>> proxyUpgradeDetailList(@PathVariable("upgradeId") Long upgradeId) {
        return adminProxyUpgradeDetailService.proxyUpgradeDetailList(upgradeId);
    }

    @Override
    public Long getLoginUserId() {
        return LoginUserUtil.getUserId();
    }

}
